//
//  PostMediaItemCellData.m
//  CKApp
//
//  Created by CC on 2020/9/12.
//  Copyright © 2020 This Moment. All rights reserved.
//

#import "PostMediaItemCellData.h"
#import "PostMediaItemCell.h"
#import "LcFoundation.h"
#import "PostingAuxiliary.h"

@implementation PostMediaItemCellData

+ (instancetype)cellDataWithMeta:(CCMediaMeta*)mediaMeta
            deleteClickedHandler:(OnCollectionCellClickedHanlder)deleteClickedHandler {
  PostMediaItemCellData* cellData = [[PostMediaItemCellData alloc] init];
  cellData->_mediaMeta = mediaMeta;
  cellData->_deleteClickedHandler = deleteClickedHandler;
  CGFloat itemWidth = (LcUIUtility.screenWidth - 36.0 - 5 * 2) / 3.0;
  cellData.cellSize = CGSizeMake(itemWidth, itemWidth);
  return cellData;
}

- (void)refreshCell:(__kindof PostMediaItemCell*)cell animated:(BOOL)animated {
  [super refreshCell:cell animated:animated];
  cell.imageView.image = self.mediaMeta.image;
  BOOL hasUploaded = self.mediaMeta.hasUploaded;
  [cell.uploadingContainer setHidden:!hasUploaded];
  cell.progressLabel.text = [NSString stringWithFormat:@"%.0f", self.mediaMeta.progress];
}

@end
